﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FanaticRock.MediaSource.BilibiliAPI.Interfaces;
using FanaticRock.BilibiliShell.Models;
using FanaticRock.Core.DI;
using FanaticRock.Core.ServiceInterfaces;

namespace FanaticRock.BilibiliShell.Services
{
    [InjectMe(typeof(IBilibiliCookieService))]
    public class BilibiliCookieService : IBilibiliCookieService
    {
        private ILocalDbService _localDbService;
        public BilibiliCookieService(ILocalDbService localDbService)
        {
            _localDbService = localDbService;
        }

        public async Task<string> GetDedeUserId()
        {
            var id = "DedeUserID";
            var cookie = await _localDbService.GetByIdAsync<BilibiliCookieInfo>(id);
            if (cookie == null) return string.Empty;
            return cookie.Value;
        }

        public Task<string> GetMId()
        {
            return GetDedeUserId();
        }

        public async Task<string> GetSESSDATA()
        {
            var id = "SESSDATA";
            var cookie = await _localDbService.GetByIdAsync<BilibiliCookieInfo>(id);
            if (cookie == null) return string.Empty;
            return cookie.Value;
        }
    }
}
